package com.dai.designpattern.prototype.shallow;

import java.util.ArrayList;
import java.util.List;

/**
 * @author daijiyong
 */
public class Test {
    public static void main(String[] args) {
        //创建原型对象
        Man man = new Man();
        man.setAge(18);
        man.setName("daijiyong");
        List<String> friends = new ArrayList<String>();
        friends.add("张三");
        friends.add("李四");
        man.setFriends(friends);

        //拷贝原型对象
        Man cloneMan = man.clone();
        cloneMan.setAge(20);
        cloneMan.getFriends().add("王五");
        System.out.println(man);
        System.out.println(cloneMan);
    }
}
